{
    /*订单修改记录 createBy 2017-06-13*/
}
import React from "react";
import Relay from "react-relay";
import {hashHistory} from 'react-router';
import Util from "../../../../../util/Util";
import { message } from 'antd';
import './css/order_modification_record.css';
import HistoryEnquiryOrderMutation from './mutation/HistoryEnquiryOrderMutation'
export default class Modification extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            order: [],
        };
        this.enterpriseId = sessionStorage.getItem('enterpriseId');
        this.orderId = this.props.orderId || this.props.location.state.oid || '';
        // this.orderId = 'TD20170612170000021112'
        this.showDetail = this.showDetail
    }

    componentWillMount() {
        this.getOrderRecord()
    }

    getOrderRecord(){
        Relay.Store.commitUpdate(
            new HistoryEnquiryOrderMutation({
                orderId: this.orderId,
                pageSize: 1000,
                pageNum: 1
            }),
            {
                onFailure: () => {
                    message.info('请求失败');
                },
                onSuccess: (response) => {
                    let errorCode = response.historyEnquiryOrder.historyEnquiryOrder.errorCode;
                    if(errorCode=='0'){
                        let order = response.historyEnquiryOrder.historyEnquiryOrder.orders;
                        this.setState({
                            order: order
                        })
                    }else {
                        if (errorCode == 500){
                            message.error('服务器错误,请联系系统管理员');
                        }
                    }
                }
            }
        )
    }

    showDetail(enquiryId, oid) {
      hashHistory.push({
        pathname:'/OrderDetailIndex/',
        state: {enquiryId: enquiryId, oid: oid,newEnquiryId:this.props.enquiryId}
      })
    }

    render() {
        return(
            <div className="order_modification_record_box">
                <ul className="order_modification_record_box_ul">
                    {
                        this.state.order ? this.state.order.map((v, i)=>{
                            return (
                                <li key={i}>
                                    <span>
                                        {Util.dateFormat_hms(v.createDate)}
                                    </span>
                                    <span>{v.versionDesc}</span>
                                    <a onClick={this.showDetail.bind(this, v.enquiryId, v.oid)}>查看详情</a>
                                </li>
                            )
                        }) : null
                    }

                </ul>
            </div>
        )
    }
}
